package com.example.mapreduce.outputformat;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * ClassName: LogOutputFormat
 * Package: com.example.mapreduce.outputformat
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-07-16
 * Time: 20:29
 */

public class LogOutputFormat extends FileOutputFormat<Text, NullWritable> {


    @Override
    public RecordWriter<Text, NullWritable> getRecordWriter(TaskAttemptContext job) throws IOException, InterruptedException {
        //他需要返回 RecordWriter 没有就创建一个返回给他
        LogRecordWriter lrw = new LogRecordWriter(job);
        //并且将这个job关联起来 这个LogOutputFormat  对应LogRecordWriter
        return lrw;
    }
}
